<?php
$this->PhpExcel->Excel();
$this->PhpExcel->titulo_reporte("SIGEPS UTILITARIO","MOVIMIENTOS PENDIENTES");
$this->PhpExcel->titulo_hoja("MOVIMIENTOS PENDIENTES");

$listadoReporte = array('normal' => 'Normal','detallado' => 'Detallado');
$ext = ($tipo == 1) ? 'xlsx' : 'ods';
$nombre = "LISTADO_MOVIMIENTOS_PENDIENTES".date("d_m_Y");
	

$this->PhpExcel->hoja->getDefaultStyle()->applyFromArray(array('font' => array('name' => 'arial','size' => 10)));
$this->PhpExcel->hoja->getStyle('A1')->applyFromArray(array('font' => array('bold' => true, 'size' => 12, 'color' => array('rgb' => '8B0000'))));
$this->PhpExcel->hoja->getStyle('A2')->applyFromArray(array('font' => array('bold' => true, 'size' => 11)));
$this->PhpExcel->hoja->getStyle('A3')->applyFromArray(array('font' => array('bold' => false,'size' => 10)));
$this->PhpExcel->hoja->getStyle('A4')->applyFromArray(array('font' => array('bold' => false,'size' => 10)));

$arrStyleTitle = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 
																				 'startcolor' => array('rgb' => '81DAF5')),
				        												 'font' => array('bold' => true, 'color' => array('rgb' => PHPExcel_Style_Color::COLOR_WHITE)),
				        												 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER));

$arrStyleTitleuno = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID,
				                                    'startcolor' => array('rgb' => 'EFFBFB')));

$arrborderTitleuno = array('style' => PHPExcel_Style_Border::BORDER_DASHDOT,'color' => array('rgb' => '000000'));
			     
$this->PhpExcel->configura_celda('A',5); //#
$this->PhpExcel->configura_celda('B',30); //AGENCIA
$this->PhpExcel->configura_celda('C',14); //FECHA
$this->PhpExcel->configura_celda('D',20); //CANTIDAD
$this->PhpExcel->configura_celda('E',20); //ENTRADAS
$this->PhpExcel->configura_celda('F',20); //SALIDAS

$index_title=6;
$index_detail=0;

$j=0;
//$tit = array('#','AGENCIA','FECHA','CANT MOV.','ENTRADAS','SALIDAS');
$tit[] = array('#','STR','C');
$tit[] = array('AGENCIA','STR','C');
$tit[] = array('FECHA','STR','C');
$tit[] = array('CANT MOV.','STR','C');
$tit[] = array('ENTRADAS','STR','C');
$tit[] = array('SALIDAS','STR','C');
foreach($tit as $columnTitle)
{
		$this->PhpExcel->valor_celda($j, $index_title, $columnTitle);
		$oColumn = $this->PhpExcel->obtener_columna($j, $index_title);
		$oRow = $this->PhpExcel->obtener_fila($j, $index_title);
		$this->PhpExcel->hoja->getStyle($oColumn.$oRow)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
		$this->PhpExcel->hoja->getStyle($oColumn.$oRow)->applyFromArray($arrStyleTitle);
		$this->PhpExcel->hoja->getStyle($oColumn.$oRow)->getBorders()->getAllBorders()->applyFromArray( $arrborderTitleuno);
		$j++;
}

$fila = 7;

for($i=0; $i<count($data); $i++)
{
		$centro=$data[$i]['cenrec'].' - '.$data[$i]['nombre'];
		$fecha=$this->Interfaz->fecha($data[$i]['fecmov']);
		$cantidad=$data[$i]['cant_mov'];
		$entrada=$data[$i]['entrada'];
		$salida=$data[$i]['despacho'];

		$valores = array();
		/*$valores[] = ($i+1);
    $valores[] = $centro;
		$valores[] = $fecha;
    $valores[] = $cantidad;
    $valores[] = $entrada;
    $valores[] = $salida;*/

		$valores[] = array(($i+1),'STR','C');
    $valores[] = array($centro,'STR','L');
		$valores[] = array($fecha,'STR','C');
    $valores[] = array($cantidad,'N','C');
    $valores[] = array($entrada,'N','C');
		$valores[] = array($salida,'N','C');

		$columna=0;
		foreach($valores as $valor)
		{
		
    		$this->PhpExcel->valor_celda($columna, $fila,  $valor);
        $oColumn = $this->PhpExcel->obtener_columna($columna, $fila);
        $oRow = $this->PhpExcel->obtener_fila($columna, $fila);
        if($fila%2==0)
        {
        		$this->PhpExcel->hoja->getStyle($oColumn.$oRow)->applyFromArray($arrStyleTitleuno);
        }
				$this->PhpExcel->hoja->getStyle($oColumn.$oRow)->getBorders()->getAllBorders()->applyFromArray($arrborderTitleuno);
				$columna++;
		}
    $fila++;
}



$this->PhpExcel->mostrar($nombre,$ext);
?>
